<template>
  <el-menu
    class="el-menu-vertical-demo left-menu"
    active-text-color="#ffd04b"
    background-color="#545c64"
    text-color="#fff"
    unique-opened
    :collapse="tab.other.isCollapse"
    :default-active="$route.path"
  >
  <div style="display: flex; justify-content: center;">
    <i>
      <img src="../assets/image/logo.png" style="width: 120px; height: 40px;"/>
    </i>
  </div>
  <el-sub-menu v-for="menu in menuList.menuData" :index="menu.path" :key="menu.path">
    <template #title>
      <el-icon>
        <component :is="menu.icon"/>
      </el-icon>
      <span>{{ menu.label }}</span>
    </template>
   <el-menu-item-group v-for="item in menu.children" :key="item.path" @click="redirect(item)">
     <el-menu-item :index="item.path" >
      <template #title>
        <el-icon>
          <component :is="item.icon"/>
        </el-icon>
        <span>{{ item.label }}</span>
      </template>
    </el-menu-item>
   </el-menu-item-group>
  </el-sub-menu>
  </el-menu>
</template>

<script lang="ts" setup>
import { useMenuData } from '@/stores/menuData';
import router from '@/router';
import { usetab } from '@/stores/usetabs';
//获取菜单栏数据
const menuList=useMenuData()
const tabs=usetab()
//路由跳转并且加tab
const redirect=((item:any)=>{
  tabs.addtab(item)
  tabs.selectActive(item.name)
  router.push({name:item.name})
})
const tab=usetab()


</script>

<style>
.left-menu{
    height: 100vh;
  }
</style>
